<?php

namespace App\Requests;

class AuthRequest extends BaseFormRequest
{
    public function rules()
    {
        $request_key = $this->getRequestKey();
        if ($request_key === 'POST/api/auth/send_code') {
            return [
                'phone' => 'required|string',
                'area_code' => 'required|string'
            ];
        } else if ($request_key === 'POST/api/auth/check_code') {
            return [
                'phone' => 'required|string',
                'area_code' => 'required|string',
                'auth_code' => 'required|string',
                'flash' => 'nullable|int|in:0,1'
            ];
        } else if ($request_key === 'POST/api/auth/login') {
            return [
                'phone' => 'required|string',
                'area_code' => 'required|string',
                'password' => 'required_without:auth_code|string',
                'auth_code' => 'required_without:password|numeric',
            ];
        } else if ($request_key === 'POST/api/auth/wechat_authorize') {
            return [
                'code' => 'required|string'
            ];
        } else if ($request_key === 'POST/api/auth/change_phone_binding') {
            return [
                'openid' => 'required|string',
                'phone' => 'required|string',
                'area_code' => 'required|string',
                'auth_code' => 'required|numeric'
            ];
        } else if ($request_key === 'POST/api/auth/change_wechat_binding') {
            return [
                'code' => 'required|string'
            ];
        } else if ($request_key === 'POST/api/auth/reset_password') {
            return [
                'phone' => 'required|string',
                'area_code' => 'required|string',
                'auth_code' => 'required|string',
                'password' => 'required|string'
            ];
        } else if ($request_key === 'POST/api/auth/check_version') {
            return [
                'build' => 'required|int',
                'platform' => 'required|string'
            ];
        }
        return [];
    }
}